package com.geek.javase.ch06.test3;

import java.util.Calendar;

/*
 *@author wangpeng
 *2025/10/14 22:34
 *@description TODO
 */
//4.求上个月的第三天是星期几？
public class Demo4 {
    public static void main(String[] args) {
        Calendar calendar = Calendar.getInstance();
        //获取当前月份
        int month = calendar.get(Calendar.MONTH);
        //获取当前月份的上个月
        calendar.set(Calendar.MONTH,month-1);
        //获取当前月份的上个月中的第三天
        calendar.set(Calendar.DAY_OF_MONTH,3);
        String[] daysOfWeek = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        System.out.println("上个月的第三天是星期几：" + daysOfWeek[dayOfWeek - 1]);

    }
}
